package com.huacloud.qw.mysql.shell.exception;

/**
 * @author ougw
 * @description 业务异常
 */
public class BusinessException extends BaseException {

    private static final long serialVersionUID = 1L;

    private static final ErrorCode DEFAULT_CODE = ErrorCode.INTERNAL_ERROR;

    private int code = DEFAULT_CODE.getCode();


    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    /**
     * @param errorCode 状态码, 这个字段会在错误信息里返回给客户端
     * @param message
     */
    public BusinessException(ErrorCode errorCode, String message) {
        this(errorCode.getCode(), message);
    }

    public BusinessException(ErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getMessage());
    }

    public int getCode() {
        return code;
    }

}
